﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Mod_StockManage_frm_IntoValidate : System.Web.UI.Page
{
    public static string strType = "5";//退货确认

    /// <summary>
    /// 页面加载事件
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        ClsPropertyDAL cls_Property = new ClsPropertyDAL();

        string strUserID = cls_Property.SetOrGetUserID;

        if (strUserID != "")
        {
            if (!IsPostBack)
            {
                ////////////////按钮权限控制 Begin /////////////////////////
                string strCurrPageID = this.Page.Request.Params["PageID"];
                this.ControlButtonVisible(strUserID, strCurrPageID);
                //////////////////////  End ///////////////////////////////

                this.GetIntoValidateByMain();
            }
            else
            {
                this.labMessage.Text = "";
                this.lblJs.Text = "";//清空Js脚本
            }

            //新增、删除按钮不可用
            //this.ibtnAdd.Enabled = false;
            //this.ibtnDelete0.Enabled = false;
            //this.ibtnAdd.ImageUrl = "../App_Images/b_18_3.gif";
            //this.ibtnDelete0.ImageUrl = "../App_Images/b_19_5.gif";
            //this.imgDelete.ImageUrl = "../App_Images/b_19_6.gif";
            //this.imgDelete.Attributes.Add("OnMouseOver", "");
            //this.imgDelete.Attributes.Add("OnMouseOut", "");
            //this.imgDelete.Attributes.Add("OnClick", "");
        }
        else
        {
            //ClsMenuDAL cls_Menu = new ClsMenuDAL();
            //string strMessage = cls_Menu.GetSystemCode("1", "00", this.ctbAdd0.Text.Trim(), 14);//取消当前系统编码
            this.Page.Session.Remove("SetOrGetUserID");
            this.Page.RegisterClientScriptBlock("Js", "<script>parent.window.location.href='../index.aspx'</script>");
        }
    }

    private void ControlButtonVisible(string UserLogID, string CurrPageID)
    {
        ClsMenuDAL cls_Menu = new ClsMenuDAL();
        DataSet dst = cls_Menu.GetCurrUserButtonPopedom(UserLogID, CurrPageID);

        if (dst != null && dst.Tables[0].Rows.Count > 0)
        {
            int intCount = dst.Tables[0].Rows.Count - 1;

            for (int i = intCount; i >= 0; i--)
            {
                int intButtonID = Int32.Parse(dst.Tables[0].Rows[i][2].ToString());

                switch (intButtonID)
                {
                    case 0:
                        this.panAdd.Visible = true;
                        break;
                    case 1:
                        this.hidButtonEdit.Value = intButtonID.ToString();
                        break;
                    case 2:
                        this.panDelete.Visible = true;
                        break;
                    case 3:
                        this.lbtnDelete1.Enabled = true;
                        break;
                    case 4:
                        this.panAudit.Visible = true;
                        break;
                    case 5:
                        this.hidButtonOAudit.Value = intButtonID.ToString();
                        break;
                    case 6:
                        this.panRef.Visible = true;
                        break;
                    case 7:
                        this.panSearch.Visible = true;
                        break;
                }
            }
        }
    }
  
    /// <summary>
    /// 主表记录翻页
    /// </summary>
    public void ChangPage(object sender, EventArgs e)
    {
        ClsPropertyDAL cls_Property = new ClsPropertyDAL();
        DataSet dst = cls_Property.SetOrGetCorporationDataSet;

        if (dst != null && dst.Tables[0].Rows.Count > 0)
        {
            string strKey = ((LinkButton)sender).CommandName;
            int intPageIndex = this.dgrdResult.CurrentPageIndex;
            int intPageCounts = this.dgrdResult.PageCount;

            if (strKey == "0")
            {
                intPageIndex = 0;
            }
            else if (strKey == "1")
            {
                if (intPageIndex > 0) intPageIndex -= 1;
            }
            else if (strKey == "2")
            {
                if (intPageIndex < intPageCounts - 1) intPageIndex += 1;
            }
            else
            {
                intPageIndex = intPageCounts - 1;
            }

            this.BindIntoValidateByDataView(dst, intPageIndex);
        }
    }

    /// <summary>
    /// 从表记录翻页
    /// </summary>
    public void ChildChangPage(object sender, EventArgs e)
    {
        //获取保存的从表中的结果集和DataGrid控件
        ClsPropertyDAL cls_Property = new ClsPropertyDAL();
        DataSet dst = cls_Property.SetOrGetChildResultDataSet;
        DataGrid dgrd = cls_Property.SetOrGetChildDataGridControl;

        if (dst != null && dgrd != null)
        {
            string strKey = ((LinkButton)sender).CommandName;
            int intPageIndex = dgrd.CurrentPageIndex;
            int intPageCounts = dgrd.PageCount;

            if (strKey == "0")
            {
                intPageIndex = 0;
            }
            else if (strKey == "1")
            {
                if (intPageIndex > 0) intPageIndex -= 1;
            }
            else if (strKey == "2")
            {
                if (intPageIndex < intPageCounts - 1) intPageIndex += 1;
            }
            else
            {
                intPageIndex = intPageCounts - 1;
            }

            this.BindIntoValidateChildByDataView(dgrd, dst, intPageIndex);
        }
    }

    /// <summary>
    /// 新增记录
    /// </summary>
    public void AddIntoValidateInfo(object sender, EventArgs e)
    {
        try
        {
            ClsIntoAffirmDAL cls_IntoAffirmDAL = new ClsIntoAffirmDAL();
            ClsPropertyDAL cls_Property = new ClsPropertyDAL();
            ClsMenuDAL cls_Menu = new ClsMenuDAL();
            ImageButton ibtnAdd = (ImageButton)sender;
            int intCommandName = Int32.Parse(ibtnAdd.CommandName);

            string strUserId = cls_Property.SetOrGetUserID;//当前用户

            if (intCommandName == 0)//打开主表添加面板
            {                
                //获取系统编码
                string strCode = cls_Menu.GetSystemCode("0", "00", "", 55);
                if (strCode != "Error")
                {
                    this.panAddResult.Visible = true;
                    this.ctbAdd0.Text = strCode;
                    this.ctsbAddOutDate.Text = System.DateTime.Today.ToShortDateString();
                    this.ctsbAddWriter.Text = strUserId;
                    this.lblJs.Text = "<script>document.getElementById('" + this.ctsbAddOutDate.ClientID + "_txtBox').focus();</script>";
                }
                else
                {
                    this.lblJs.Text = "<script>alert('新增记录失败，请重试！')</script>";
                }  
            }
            else if (intCommandName == 1)//关闭主表添加面板
            {
                this.panAddResult.Visible = false;
            }
            else if (intCommandName == 2)//保存主表添加记录
            {
                //保存主表新增记录的代码
                string strDm_no = this.ctbAdd0.Text.Trim();//出库单据号
                DateTime dtDm_date = DateTime.Parse(this.ctsbAddOutDate.Text.Trim());//出库日期
                string strRetDm_no = this.ctsbAddRetuBodNo.Text.Trim();//采购退货单号
                DateTime dtRetDm_date = DateTime.Parse(this.ctbAddRetuDate.Text.Trim());//退货日期
                string strPr_id = this.ctbAddProvide.Text.Trim();//供应商
                string strDepot = this.ctbAddDepot.Text.Trim();//仓库
                string strDept = this.ctbAddDept.Text.Trim();//采购部门
                string strStocker = this.ctbAddStocker.Text.Trim();//采购员
                decimal dDm_money = decimal.Parse(this.ctbAddSumMoney.Text.ToString().Trim());//总金额
                int iDm_Validate = 0;//确认状态      
                string strCr_Remark = this.ctbAddRemark.Text.Trim();//备注
               
                Boolean bolIsCussee = cls_IntoAffirmDAL.AddIntoValid(strType, strDm_no, dtDm_date, strRetDm_no, dtRetDm_date, strPr_id,
                                    strDept, strDepot, dDm_money, iDm_Validate, strUserId, "", strCr_Remark);
                if (bolIsCussee)
                {
                    //重新绑定结果
                    this.GetIntoValidateByMain();

                    //主表新增后直接打开从表进行新增从表记录 Begin///////////////////////////
                    this.panAddResult.Visible = false;
                    ImageButton ibtn = new ImageButton();

                    int intItems = this.dgrdResult.Items.Count - 1;

                    for (int i = intItems; i >= 0; i--)
                    {
                        string strRs_No = ((CuTextBox)this.dgrdResult.Items[i].FindControl("ctbRs0")).Text.Trim();

                        if (strRs_No == strDm_no)
                        {
                            ibtn = (ImageButton)this.dgrdResult.Items[i].FindControl("ibtnOpenChild");
                            break;
                        }
                    }

                    this.OpenChildResult(ibtn, null);
                    this.AddIntoValidateInfo(this.ibtnAdd, null);
                    //主表新增后直接打开从表进行新增从表记录 End///////////////////////////
                }
                else
                {
                    Response.Write("<script>alert('新增失败！');</script>");
                }
            }
            else
            {
                int intIndex = Int32.Parse(this.ibtnAdd.CommandArgument);

                Panel panChildAddResult = (Panel)this.dgrdResult.Items[intIndex].FindControl("panChildAddResult");

                if (intCommandName == 3)//关闭从表添加面板
                {
                    panChildAddResult.Visible = false;
                }
                else if (intCommandName == 4)//保存从表添加记录----------------------------
                {
                    //此处写保存从表新增记录的代码
                    //DataGrid dgrd = new DataGrid();
                    //string strDm_No = "";//主表单据号
                    //int intChildCount = this.dgrdResult.Items.Count;

                    //for (int i = 0; i < intChildCount; i++)
                    //{
                    //    Panel panItem = (Panel)this.dgrdResult.Items[i].FindControl("panItem");

                    //    if (panItem.Visible)
                    //    {
                    //        strDm_No = ((CuTextBox)this.dgrdResult.Items[i].FindControl("ctbRs0")).Text.Trim();//主表单据号
                    //        dgrd = (DataGrid)this.dgrdResult.Items[i].FindControl("dgrdChildResult");
                    //        break;
                    //    }
                    //}
                    //string strProductId = ((CuTextSelectBox)dgrdResult.Items[intIndex].FindControl("ctsbChildAdd0")).Text.Trim();//商品编号
                    //int iChildAcount = int.Parse(((CuTextBox)dgrdResult.Items[intIndex].FindControl("ctbChildAdd3")).Text.Trim());////数量
                    //decimal dChildPrice = decimal.Parse(((CuTextBox)dgrdResult.Items[intIndex].FindControl("ctbChildAdd5")).Text.Trim());//单价
                    //string strChildRemark = ((CuTextBox)dgrdResult.Items[intIndex].FindControl("ctbChildAdd8")).Text.Trim();//备注

                    //Boolean bolIsCussee = cls_IntoAffirmDAL.AddChildSellBack(strDm_No, strProductId, iChildAcount, dChildPrice, strChildRemark);
                    //if (!bolIsCussee)
                    //{
                    //    this.Page.RegisterClientScriptBlock("Js", "<script>alert('新增销售退货明细失败，请重试！')</script>");
                    //}

                    //新增后重新绑定明细表
                    //ClsIntoAffirmDAL cls_SellBack = new ClsIntoAffirmDAL();
                    //DataSet dst = cls_SellBack.GetSellBackChilds(strDm_No);

                    //if (dst != null && dst.Tables[0].Rows.Count > 0)
                    //{
                    //    this.BindIntoValidateChildByDataView(dgrd, dst, 0);
                    //}

                }
                else if (intCommandName == 5)//打开从表添加面板
                {
                    //panChildAddResult.Visible = true;
                    CuTextSelectBox ctsbChildAdd0 = (CuTextSelectBox)this.dgrdResult.Items[intIndex].FindControl("ctsbChildAdd0");
                    this.lblJs.Text = "<script>document.getElementById('" + ctsbChildAdd0.ClientID + "_txtBox').focus();</script>";
                }
            }
        }
        catch
        {
            Response.Write("<script language='javascript'>alert('请输入正确的格式和必填项！');</script>");
        }
    }

    /// <summary>
    /// 修改记录
    /// </summary>
    public void UpDateIntoValidateInfo(object sender, EventArgs e)
    {
        try
        {
            ClsIntoAffirmDAL cls_IntoAffirmDAL = new ClsIntoAffirmDAL();
            ClsPropertyDAL cls_Property = new ClsPropertyDAL();
            ClsIntoAffirmDAL ClsIntoAffirmDAL = new ClsIntoAffirmDAL();//用同一个数据层。因为同一个表，功能只是一个要确认，一个不要
            ImageButton ibtnUpdate = (ImageButton)sender;
            string strUserId = cls_Property.SetOrGetUserID;
            int intCommandName = Int32.Parse(ibtnUpdate.CommandName);
            int intIndex = Int32.Parse(ibtnUpdate.CommandArgument);

            if (intCommandName == 0)//主表确认
            {
                int intCount = this.dgrdResult.Items.Count;

                for (int i = 0; i < intCount; i++)
                {
                    CheckBox chkBox = (CheckBox)this.dgrdResult.Items[i].FindControl("chkRsSelect");
                    if (chkBox.Checked)
                    {
                        //此处写确认的代码
                        string strTm_No = ((CuTextBox)this.dgrdResult.Items[i].FindControl("ctbRs0")).Text.Trim();//主表ID号
                        ////检查是否可以确认
                        //string strReStatu = cls_IntoAffirmDAL.ChkIsAudit(strType, strTm_No);
                        //if (strReStatu == "0")//0:可以确认，否则不可以
                        //{
                            string strReturn = cls_IntoAffirmDAL.CheckWhetherAudtit(strTm_No, strType, 0, strUserId);
                            string[] arrReValue = strReturn.Split(new char[] { '|' });                        
                            if (arrReValue[0] == "N")//不可以取消确认，得到返回的批号
                            {
                                if (arrReValue[1].Length > 0 && arrReValue[2].Length > 0)
                                {
                                    this.labMessage.Text = "<script language='javascript'>alert('当前" + arrReValue[1] + "商品" + arrReValue[2] + "批号未入库,请确认！');</script>";
                                }
                                else
                                {
                                    this.labMessage.Text = "<script language='javascript'>alert('当前" + arrReValue[1] + "商品未入库,请确认！');</script>";
                                }
                            }
                            else if (arrReValue[0] == "Q")
                            {
                                if (arrReValue[1].Length > 0 && arrReValue[2].Length > 0)
                                {
                                    this.labMessage.Text = "<script language='javascript'>alert('当前" + arrReValue[1] + "商品" + arrReValue[2] + "批号库存不足,请调整！');</script>";
                                }
                                else
                                {
                                    this.labMessage.Text = "<script language='javascript'>alert('当前" + arrReValue[1] + "商品库存不足,请确认！');</script>";
                                }
                            }
                            else//成功返回“0”
                            {
                                if (strReturn != "0")
                                {
                                    Response.Write("<script>alert('确认失败！');</script>");
                                }

                                //重新绑定结果
                                this.GetIntoValidateByMain();
                            }
                    //}
                    //else
                    //{
                    //    this.labMessage.Text = "<script language='javascript'>alert('商品数量不能>剩余未入库数量,请检查！');</script>！";
                    //}

                    }
                }

                //重新绑定结果
                this.GetIntoValidateByMain();
            }
            else if (intCommandName == 3)//主表取消确认
            {
                //此处写取消确认的代码
                int iIndex = int.Parse(ibtnUpdate.CommandArgument);
                string strTm_No = ((CuTextBox)this.dgrdResult.Items[iIndex].FindControl("ctbRs0")).Text.Trim();//主表ID号
                                
                string strReturn = cls_IntoAffirmDAL.CheckWhetherAudtit(strTm_No, strType, 1, "思捷用户");
                if (strReturn != "0")
                {
                    Response.Write("<script>alert('确认失败！');</script>");
                }
                else
                {
                    //重新绑定结果
                    this.GetIntoValidateByMain();
                }
            }
            else if (intCommandName == 1 || intCommandName == 2 || intCommandName == 4)//主表编辑
            {
                CheckBox chkRsSelect = (CheckBox)this.dgrdResult.Items[intIndex].FindControl("chkRsSelect");
                ImageButton ibtnRsCancel = (ImageButton)this.dgrdResult.Items[intIndex].FindControl("ibtnRsCancel");
                ImageButton ibtnRsEdit = (ImageButton)this.dgrdResult.Items[intIndex].FindControl("ibtnRsEdit");
                ImageButton ibtnRsServer = (ImageButton)this.dgrdResult.Items[intIndex].FindControl("ibtnRsServer");
                ImageButton ibtnRsOAudit = (ImageButton)this.dgrdResult.Items[intIndex].FindControl("ibtnRsOAudit");

                CuTextBox ctbRs0 = (CuTextBox)this.dgrdResult.Items[intIndex].FindControl("ctbRs0");//出库单号
                CuTextSelectBox ctsbRsOut_date = (CuTextSelectBox)this.dgrdResult.Items[intIndex].FindControl("ctsbRsOut_date");//出库日期
                CuTextSelectBox ctsbRs1 = (CuTextSelectBox)this.dgrdResult.Items[intIndex].FindControl("ctsbRs1");
                CuTextBox ctbRs2 = (CuTextBox)this.dgrdResult.Items[intIndex].FindControl("ctbRs2");
                CuTextBox ctbRs3 = (CuTextBox)this.dgrdResult.Items[intIndex].FindControl("ctbRs3");
                CuTextBox ctbSumMoney = (CuTextBox)this.dgrdResult.Items[intIndex].FindControl("ctbRs1");

                DropDownList drpValid = (DropDownList)this.dgrdResult.Items[intIndex].FindControl("drpValid");
                CuTextBox ctbWriter = (CuTextBox)this.dgrdResult.Items[intIndex].FindControl("ctbWriter");
                CuTextBox ctbRemark = (CuTextBox)this.dgrdResult.Items[intIndex].FindControl("ctbRemark");//备注

                //Label labValid = (Label)this.dgrdResult.Items[intIndex].FindControl("labValid");                
                //Label labCancel = (Label)this.dgrdResult.Items[intIndex].FindControl("labCancel");
                //Label labStop = (Label)this.dgrdResult.Items[intIndex].FindControl("labStop");


                if (intCommandName == 1)//取消编辑
                {
                    chkRsSelect.Visible = ibtnRsEdit.Visible = true;
                    ibtnRsCancel.Visible = ibtnRsServer.Visible = ibtnRsOAudit.Visible = false;
                    ctbRs0.ReadOnly = ctsbRs1.ReadOnly = ctbRs2.ReadOnly = ctbRs3.ReadOnly = true;
                }
                else if (intCommandName == 2)//编辑
                {
                    ibtnRsCancel.Visible = ibtnRsServer.Visible = drpValid.Visible = true;
                    chkRsSelect.Visible = ibtnRsEdit.Visible = ibtnRsOAudit.Visible = false;//labValid.Visible = false;
                    ctsbRsOut_date.ReadOnly = ctbRemark.ReadOnly = false;                    
                    this.lblJs.Text = "<script>document.getElementById('" + ctsbRsOut_date.ClientID + "_txtBox').select();document.getElementById('" + ctsbRsOut_date.ClientID + "_txtBox').focus();</script>";
                }
                else//保存编辑
                {
                    chkRsSelect.Visible = ibtnRsEdit.Visible = true;
                    ibtnRsCancel.Visible = ibtnRsServer.Visible = ibtnRsOAudit.Visible = false;
                    ctbRs0.ReadOnly = ctsbRs1.ReadOnly = ctbRs2.ReadOnly = ctbRs3.ReadOnly = true;

                    //此处写保存编辑的代码
                    //Boolean bolIsCussee = cls_IntoAffirmDAL.UpDateSellBackAud(ctbRs0.Text.Trim(), DateTime.Parse(ctsbRs0.Text.Trim()), ctsbRs1.Text.Trim(),
                    //                        decimal.Parse(ctbSumMoney.Text.Trim()),
                    //                       int.Parse(drpValid.SelectedValue), ctbRs2.Text.Trim(), ctbRs3.Text.Trim(), ctbRemark.Text.Trim());
                    Boolean bolIsCussee = ClsIntoAffirmDAL.UpDateIntoAffirm(ctbRs0.Text.Trim(), DateTime.Parse(ctsbRsOut_date.Text.Trim()),
                        ctbRemark.Text.Trim());
                    if (!bolIsCussee)
                    {
                        Response.Write("<script>alert('修改失败！');</script>");
                    }

                    //重新绑定结果
                    this.GetIntoValidateByMain();
                }
            }
            else//从表相关操作
            {
                //从表修改记录的代码
                DataGrid dgrd = new DataGrid();
                string strOut_No = "";//主表单据号
                int intChildCount = this.dgrdResult.Items.Count;

                for (int i = 0; i < intChildCount; i++)
                {
                    Panel panItem = (Panel)this.dgrdResult.Items[i].FindControl("panItem");

                    if (panItem.Visible)
                    {
                        strOut_No = ((CuTextBox)this.dgrdResult.Items[i].FindControl("ctbRs0")).Text.Trim();//主表单据号
                        dgrd = (DataGrid)this.dgrdResult.Items[i].FindControl("dgrdChildResult");
                        break;
                    }
                }

                CheckBox chkChildRsSelect = (CheckBox)dgrd.Items[intIndex].FindControl("chkChildRsSelect");
                ImageButton ibtnChildRsCancel = (ImageButton)dgrd.Items[intIndex].FindControl("ibtnChildRsCancel");
                ImageButton ibtnChildRsEdit = (ImageButton)dgrd.Items[intIndex].FindControl("ibtnChildRsEdit");
                ImageButton ibtnChildRsServer = (ImageButton)dgrd.Items[intIndex].FindControl("ibtnChildRsServer");

                CuTextSelectBox ctsbProductId = (CuTextSelectBox)dgrd.Items[intIndex].FindControl("ctsbChildRs0");//商品编号
                CuTextBox ctbQry = (CuTextBox)dgrd.Items[intIndex].FindControl("ctbChildRsQty");//数量
                CuTextBox ctbBatchNo = (CuTextBox)dgrd.Items[intIndex].FindControl("ctbChildRsBatchNo");//批号
                CuTextBox ctbPrice = (CuTextBox)dgrd.Items[intIndex].FindControl("ctbChildRsPrice");//单价
                CuTextBox ctbRemark = (CuTextBox)dgrd.Items[intIndex].FindControl("ctbChildRs8");//备注

                if (intCommandName == 6)//从表编辑
                {
                    chkChildRsSelect.Visible = ibtnChildRsEdit.Visible = false;
                    ibtnChildRsCancel.Visible = ibtnChildRsServer.Visible = true;
                    ctbBatchNo.ReadOnly = ctbRemark.ReadOnly = false;
                }
                else if (intCommandName == 5)//从表取消编辑
                {
                    chkChildRsSelect.Visible = ibtnChildRsEdit.Visible = true;
                    ibtnChildRsCancel.Visible = ibtnChildRsServer.Visible = false;
                    ctbBatchNo.ReadOnly = ctbRemark.ReadOnly = true;
                }
                else if (intCommandName == 7)//从表保存编辑
                {                    
                    int iId = int.Parse(dgrd.Items[intIndex].Cells[1].Text.Trim());
                    Boolean bolIsCussee = cls_IntoAffirmDAL.UpDateIntoAffirmD(iId,strOut_No, ctsbProductId.Text.Trim(), ctbBatchNo.Text.Trim(),
                       int.Parse(ctbQry.Text.Trim()), ctbRemark.Text.Trim());
                    if (!bolIsCussee)
                    {
                        this.Page.RegisterClientScriptBlock("Js", "<script>alert('修改采购退货确认明细失败，请重试！')</script>");
                    }
                    else
                    {
                        //修改后重新绑定明细表
                        //ClsIntoAffirmDAL clsIntoAffirm = new ClsIntoAffirmDAL();
                        DataSet dst = cls_IntoAffirmDAL.GetIntoAffirmChilds(strOut_No, strType);

                        if (dst != null && dst.Tables[0].Rows.Count > 0)
                        {
                            this.BindIntoValidateChildByDataView(dgrd, dst, 0);
                        }
                    }
                }
            }
        }
        catch
        {
            Response.Write("<script language='javascript'>alert('请输入正确的格式和必填项！');</script>");
        }
    }

    /// <summary>
    /// 删除记录
    /// </summary>
    public void lbtnDelete_Click(object sender, EventArgs e)
    {
        int intCommandName = Int32.Parse(((LinkButton)sender).CommandName);

        this.DeleteIntoValidateInfo(intCommandName);
    }

    /// <summary>
    /// 展开或收缩从表信息
    /// </summary>
    public void OpenChildResult(object sender, ImageClickEventArgs e)
    {
        ImageButton ibtnOpen = (ImageButton)sender;
        int intCommandName = Int32.Parse(ibtnOpen.CommandName);
        int intIndex = Int32.Parse(ibtnOpen.CommandArgument);
        int intCount = this.dgrdResult.Items.Count;
        bool is_audit = bool.Parse(this.dgrdResult.Items[intIndex].Cells[1].Text);

        CheckBox chkRsSelect = (CheckBox)this.dgrdResult.Items[intIndex].FindControl("chkRsSelect");
        ImageButton ibtnOpenChild = (ImageButton)this.dgrdResult.Items[intIndex].FindControl("ibtnOpenChild");
        ImageButton ibtnRsCancel = (ImageButton)this.dgrdResult.Items[intIndex].FindControl("ibtnRsCancel");
        ImageButton ibtnRsEdit = (ImageButton)this.dgrdResult.Items[intIndex].FindControl("ibtnRsEdit");
        ImageButton ibtnRsServer = (ImageButton)this.dgrdResult.Items[intIndex].FindControl("ibtnRsServer");
        ImageButton ibtnRsOAudit = (ImageButton)this.dgrdResult.Items[intIndex].FindControl("ibtnRsOAudit");
        Panel panShowChildResult = (Panel)this.dgrdResult.Items[intIndex].FindControl("panShowChildResult");

        if (intCommandName == 0)//展开
        {
            string strOut_No = ((CuTextBox)this.dgrdResult.Items[intIndex].FindControl("ctbRs0")).Text.Trim();//出库主单号
            string strOut_Date = ((CuTextSelectBox)this.dgrdResult.Items[intIndex].FindControl("ctsbRsOut_date")).Text.Trim();//出库主单日期
            this.labbodNoAndDate.Text = strOut_No + "*" + strOut_Date;

            for (int i = 0; i < intCount; i++)
            {
                //找到展开的项
                Panel panItem = (Panel)this.dgrdResult.Items[i].FindControl("panItem");

                if (i == intIndex)
                {
                    panItem.Visible = true;
                }
                else
                {
                    panItem.Visible = false;
                }
            }

            //主表展开后则不可操作
            this.ibtnAdd.Enabled = false;
            this.ibtnAdd.ImageUrl = "../App_Images/b_18_3.gif";
            this.ibtnDelete0.Enabled = false;
            this.lbtnDelete0.Enabled = false;
            this.lbtnDelete1.Enabled = false;

            this.ibtnAdd.CommandName = "5";
            this.ibtnRef.CommandName = "1";
            this.ibtnDelete0.CommandName = "-1";//删除从表用（假删除）
            this.lbtnDelete0.CommandName = "-2";//删除从表用（假删除）
            this.lbtnDelete1.CommandName = "-3";//删除从表用（真删除）
            this.ibtnAdd.CommandArgument = intIndex.ToString();
            panShowChildResult.Visible = true;
            ibtnOpenChild.CommandName = "1";
            ibtnOpenChild.ImageUrl = "../App_Images/ico/10.gif";
            ibtnRsEdit.ImageUrl = "../App_Images/ico/14.gif";
            ibtnRsServer.ImageUrl = "../App_Images/ico/16.gif";
            ibtnRsOAudit.ImageUrl = "../App_Images/ico/17.gif";
            ibtnRsCancel.ImageUrl = "../App_Images/ico/18.gif";
            this.ibtnAudit.ImageUrl = "../App_Images/b_21_3.gif";
            this.ibtnAudit.Enabled = chkRsSelect.Enabled = ibtnRsCancel.Enabled = ibtnRsEdit.Enabled = ibtnRsServer.Enabled = ibtnRsOAudit.Enabled = false;
            this.lblRsCounts.Enabled = this.lblPageCounts.Enabled = this.lblCurrPage.Enabled = this.lbtnFirst.Enabled = this.lbtnPrev.Enabled = this.lbtnNext.Enabled = this.lbtnEnd.Enabled = this.lblGoTxt1.Enabled = this.txtGo.Enabled = this.lblGoTxt2.Enabled = false;

            //如果主表确认后则从表不可操作
            if (is_audit)
            {
                this.ibtnAdd.Enabled = this.ibtnDelete0.Enabled = false;
                this.ibtnAdd.ImageUrl = "../App_Images/b_18_3.gif";
                this.ibtnDelete0.ImageUrl = "../App_Images/b_19_5.gif";
                this.imgDelete.ImageUrl = "../App_Images/b_19_6.gif";
                this.imgDelete.Attributes.Add("OnMouseOver", "");
                this.imgDelete.Attributes.Add("OnMouseOut", "");
                this.imgDelete.Attributes.Add("OnClick", "");
            }

            //显示从表信息
            CuTextBox ctbRs0 = (CuTextBox)this.dgrdResult.Items[intIndex].FindControl("ctbRs0");
            ClsIntoAffirmDAL cls_IntoAffirm = new ClsIntoAffirmDAL();
            DataSet dst = cls_IntoAffirm.GetIntoAffirmChilds(ctbRs0.Text.Trim(), strType);

            if (dst != null && dst.Tables[0].Rows.Count > 0)
            {
                DataGrid dgrd = (DataGrid)this.dgrdResult.Items[intIndex].FindControl("dgrdChildResult");

                //绑定从表信息
                this.BindIntoValidateChildByDataView(dgrd, dst, 0);
            }
        }
        else//收缩
        {
            //收缩后都可操作
            this.ibtnAdd.Enabled = true;
            this.ibtnDelete0.Enabled = true;
            this.lbtnDelete0.Enabled = true;
            this.lbtnDelete1.Enabled = true;

            this.ibtnAdd.CommandName = "0";
            this.ibtnRef.CommandName = "0";
            this.ibtnDelete0.CommandName = "0";//恢复删除主表用（真）
            this.lbtnDelete0.CommandName = "0";//恢复删除主表用（假）
            this.lbtnDelete1.CommandName = "1";//恢复删除主表用（假）
            panShowChildResult.Visible = false;
            ibtnOpenChild.CommandName = "0";
            ibtnOpenChild.ImageUrl = "../App_Images/ico/9.gif";
            ibtnRsEdit.ImageUrl = "../App_Images/ico/12.gif";
            ibtnRsServer.ImageUrl = "../App_Images/ico/11.gif";
            ibtnRsOAudit.ImageUrl = "../App_Images/ico/8.gif";
            ibtnRsCancel.ImageUrl = "../App_Images/ico/4.gif";
            this.ibtnAudit.ImageUrl = "../App_Images/b_21_1.gif";
            this.ibtnAdd.ImageUrl = "../App_Images/b_18_1.gif";
            this.ibtnDelete0.ImageUrl = "../App_Images/b_19_1.gif";
            this.imgDelete.ImageUrl = "../App_Images/b_19_4.gif";
            this.imgDelete.Attributes.Add("OnMouseOver", "ChangImage(this, '../App_Images/b_19_3.gif');ChangImage(document.all.ibtnDelete0, '../App_Images/b_19_2.gif')");
            this.imgDelete.Attributes.Add("OnMouseOut", "ChangImage(this, '../App_Images/b_19_4.gif');ChangImage(document.all.ibtnDelete0, '../App_Images/b_19_1.gif')");
            this.imgDelete.Attributes.Add("OnClick", "ChildMenuVisible()");
            this.ibtnAdd.Enabled = this.ibtnDelete0.Enabled = false;
            //this.ibtnAudit.Enabled = chkRsSelect.Enabled = ibtnRsCancel.Enabled = ibtnRsEdit.Enabled = ibtnRsServer.Enabled = ibtnRsOAudit.Enabled = true;
            this.ibtnAdd.Enabled = this.ibtnDelete0.Enabled = this.ibtnAudit.Enabled = chkRsSelect.Enabled = ibtnRsCancel.Enabled = ibtnRsEdit.Enabled = ibtnRsServer.Enabled = ibtnRsOAudit.Enabled = true;

            //重新绑定
            ClsPropertyDAL cls_Property = new ClsPropertyDAL();
            DataSet dst = cls_Property.SetOrGetCorporationDataSet;
            this.BindIntoValidateByDataView(dst, this.dgrdResult.CurrentPageIndex);
        }
    }

    /// <summary>
    /// 获取所有主表记录
    /// </summary>
    private void GetIntoValidateByMain()
    {
        ClsPropertyDAL cls_Property = new ClsPropertyDAL();

        string strUserID = cls_Property.SetOrGetUserID;

        if (strUserID != "")
        {
            ClsStockValidateDAL cls_IntoValidate = new ClsStockValidateDAL();

            DataSet dst = cls_IntoValidate.GetIntoValidateMains(strUserID,strType);

            if (dst != null && dst.Tables[0].Rows.Count > 0)
            {
                cls_Property.SetOrGetCorporationDataSet = dst;

                this.BindIntoValidateByDataView(dst, 0);
            }
            else
            {
                this.dgrdResult.CurrentPageIndex = 0;
                this.dgrdResult.DataSource = null;
                this.dgrdResult.DataBind();
                this.lblRsCounts.Text = "共0条记录";
                this.lblPageCounts.Text = "共0页";
                this.lblCurrPage.Text = "当前第0页";
                this.lbtnFirst.Enabled = this.lbtnPrev.Enabled = this.lbtnNext.Enabled = this.lbtnEnd.Enabled = this.txtGo.Enabled = false;
                this.lblRsCounts.Enabled = this.lblPageCounts.Enabled = this.lblCurrPage.Enabled = this.lblGoTxt1.Enabled = this.lblGoTxt2.Enabled = false;
            }
        }
        else
        {
            this.Page.Session.Remove("SetOrGetUserID");
            this.Page.RegisterClientScriptBlock("Js", "<script>parent.window.location.href='../index.aspx'</script>");
        }
    }

    /// <summary>
    /// 绑定主表信息到数据控件
    /// </summary>
    private void BindIntoValidateByDataView(DataSet dst, int CurrPageIndex)
    {
        if (dst != null && dst.Tables[0].Rows.Count > 0)
        {
            this.dgrdResult.CurrentPageIndex = CurrPageIndex;
            this.dgrdResult.DataSource = dst;
            this.dgrdResult.DataBind();

            this.lblRsCounts.Text = "共" + dst.Tables[0].Rows.Count + "条记录";
            this.lblPageCounts.Text = "共" + this.dgrdResult.PageCount + "页";
            this.lblCurrPage.Text = "当前第" + (this.dgrdResult.CurrentPageIndex + 1) + "页";
            this.lbtnFirst.Enabled = this.lbtnPrev.Enabled = this.lbtnNext.Enabled = this.lbtnEnd.Enabled = this.txtGo.Enabled = true;
            this.lblRsCounts.Enabled = this.lblPageCounts.Enabled = this.lblCurrPage.Enabled = this.lblGoTxt1.Enabled = this.lblGoTxt2.Enabled = true;

            if (this.dgrdResult.PageCount == 1)
            {
                this.lbtnFirst.Enabled = this.lbtnPrev.Enabled = this.lbtnNext.Enabled = this.lbtnEnd.Enabled = false;
                this.lblGoTxt1.Enabled = this.txtGo.Enabled = this.lblGoTxt2.Enabled = false;
            }
            else if (this.dgrdResult.CurrentPageIndex == this.dgrdResult.PageCount - 1)
            {
                this.lbtnNext.Enabled = this.lbtnEnd.Enabled = false;
            }
            else if (this.dgrdResult.CurrentPageIndex == 0)
            {
                this.lbtnFirst.Enabled = this.lbtnPrev.Enabled = false;
            }
        }
        else
        {
            this.dgrdResult.DataSource = null;
            this.dgrdResult.DataBind();
        }
    }

    /// <summary>
    /// 绑定从表信息到数据控件
    /// </summary>
    private void BindIntoValidateChildByDataView(DataGrid dgrd, DataSet dst, int CurrPageIndex)
    {
        if (dgrd != null && dst != null)
        {
            dgrd.CurrentPageIndex = CurrPageIndex;
            dgrd.DataSource = dst;
            dgrd.DataBind();

            int intIndex = Int32.Parse(dgrd.ToolTip);
            int intItems = dgrd.Items.Count;

            Label lblChildRsCounts = (Label)this.dgrdResult.Items[intIndex].FindControl("lblChildRsCounts");
            Label lblChildPageCounts = (Label)this.dgrdResult.Items[intIndex].FindControl("lblChildPageCounts");
            Label lblChildCurrPage = (Label)this.dgrdResult.Items[intIndex].FindControl("lblChildCurrPage");
            LinkButton lbtnChildFirst = (LinkButton)this.dgrdResult.Items[intIndex].FindControl("lbtnChildFirst");
            LinkButton lbtnChildPrev = (LinkButton)this.dgrdResult.Items[intIndex].FindControl("lbtnChildPrev");
            LinkButton lbtnChildNext = (LinkButton)this.dgrdResult.Items[intIndex].FindControl("lbtnChildNext");
            LinkButton lbtnChildEnd = (LinkButton)this.dgrdResult.Items[intIndex].FindControl("lbtnChildEnd");

            lblChildRsCounts.Text = "共" + dst.Tables[0].Rows.Count + "条明细记录";
            lblChildPageCounts.Text = "共" + dgrd.PageCount + "页";
            lblChildCurrPage.Text = "当前第" + (dgrd.CurrentPageIndex + 1) + "页";
            lbtnChildFirst.Enabled = lbtnChildPrev.Enabled = lbtnChildNext.Enabled = lbtnChildEnd.Enabled = true;
            lblChildRsCounts.Enabled = lblChildPageCounts.Enabled = lblChildCurrPage.Enabled = true;

            if (dgrd.PageCount == 1)
            {
                lbtnChildFirst.Enabled = lbtnChildPrev.Enabled = lbtnChildNext.Enabled = lbtnChildEnd.Enabled = false;
            }
            else if (dgrd.CurrentPageIndex == dgrd.PageCount - 1)
            {
                lbtnChildNext.Enabled = lbtnChildEnd.Enabled = false;
            }
            else if (dgrd.CurrentPageIndex == 0)
            {
                lbtnChildFirst.Enabled = lbtnChildPrev.Enabled = false;
            }

            //判断从表中的记录是否可操作
            //for (int i = 0; i < intItems; i++)
            //{
            //    CheckBox chkChildRsSelect = (CheckBox)dgrd.Items[i].FindControl("chkChildRsSelect");
            //    ImageButton ibtnChildRsEdit = (ImageButton)dgrd.Items[i].FindControl("ibtnChildRsEdit");

            //    if (!this.ibtnAdd.Enabled)
            //    {
            //        chkChildRsSelect.Enabled = ibtnChildRsEdit.Enabled = false;
            //        ibtnChildRsEdit.ImageUrl = "../App_Images/ico/14.gif";
            //    }
            //    else
            //    {
            //        chkChildRsSelect.Enabled = ibtnChildRsEdit.Enabled = true;
            //        ibtnChildRsEdit.ImageUrl = "../App_Images/ico/12.gif";
            //    }
            //}

            //保存从表中的结果集和DataGrid控件用于从表中的翻页
            ClsPropertyDAL cls_Property = new ClsPropertyDAL();
            cls_Property.SetOrGetChildResultDataSet = dst;
            cls_Property.SetOrGetChildDataGridControl = dgrd;
        }
    }

    /// <summary>
    /// 删除记录
    /// </summary>
    private void DeleteIntoValidateInfo(int CommandName)
    {
        ClsIntoAffirmDAL cls_IntoAffirmDAL = new ClsIntoAffirmDAL();
        int intCount = this.dgrdResult.Items.Count;
        //int iChildCount = this.dgrdChildResult..this
        if (CommandName == 0 || CommandName == 1)//删除主表(0:假删除;1:真删除)
        {
            for (int i = 0; i < intCount; i++)
            {
                CheckBox chkBox = (CheckBox)this.dgrdResult.Items[i].FindControl("chkRsSelect");

                if (chkBox.Checked)
                {
                    CuTextBox txtBox = (CuTextBox)this.dgrdResult.Items[i].FindControl("ctbRs0");

                    Boolean bolIsCussee = cls_IntoAffirmDAL.DeleteIntoAffirm(strType,txtBox.Text.Trim(), CommandName);

                    if (!bolIsCussee)
                    {
                        this.Page.RegisterClientScriptBlock("Js", "<script>alert('删除退货确认信息失败，请重试！')</script>");
                    }
                }
            }

            //重新绑定结果
            this.GetIntoValidateByMain();
        }
        else if (CommandName == -1 || CommandName == -2 || CommandName == -3)//删除从表:-1,-2假删除,-3真删除，
        {
            DataGrid dgrd = new DataGrid();
            string strOut_No = "";//出库单据号
            int intChildCount = this.dgrdResult.Items.Count;

            for (int i = 0; i < intChildCount; i++)
            {
                Panel panItem = (Panel)this.dgrdResult.Items[i].FindControl("panItem");

                if (panItem.Visible)
                {
                    strOut_No = ((CuTextBox)this.dgrdResult.Items[i].FindControl("ctbRs0")).Text.Trim();
                    dgrd = (DataGrid)this.dgrdResult.Items[i].FindControl("dgrdChildResult");
                    break;
                }
            }

            int intChildItem = dgrd.Items.Count;

            for (int j = 0; j < intChildItem; j++)
            {
                CheckBox checkBox = (CheckBox)dgrd.Items[j].FindControl("chkChildRsSelect");

                if (checkBox.Checked)
                {             
                    string strIm_no = ((CuTextSelectBox)dgrd.Items[j].FindControl("ctsbChildRs0")).Text.Trim();//明细产品编号
                    string strBatch_no = ((CuTextBox)dgrd.Items[j].FindControl("ctbChildRsBatchNo")).Text.Trim();//批号

                    Boolean bolIsCussee = cls_IntoAffirmDAL.DeleteChildIntoAffirm(strType, strOut_No, strIm_no, strBatch_no, CommandName);

                    if (!bolIsCussee)
                    {
                        this.Page.RegisterClientScriptBlock("Js", "<script>alert('删除采购退货明细失败，请重试！')</script>");
                    }
                }
            }

            DataSet dst = cls_IntoAffirmDAL.GetIntoAffirmChilds(strOut_No, strType);
            if (dst != null && dst.Tables[0].Rows.Count > 0)
            {
                this.BindIntoValidateChildByDataView(dgrd, dst, 0);
            }
            else
            {
                dgrd.DataSource = null;
                dgrd.DataBind();
            }
        }
    }

    /// <summary>
    /// 删除记录事件
    /// </summary>
    protected void ibtnDelete0_Click(object sender, ImageClickEventArgs e)
    {
        int intCommandName = Int32.Parse(((ImageButton)sender).CommandName);

        this.DeleteIntoValidateInfo(intCommandName);
    }

    /// <summary>
    /// 记录页面跳转
    /// </summary>
    protected void txtGo_TextChanged(object sender, EventArgs e)
    {
        ClsPropertyDAL cls_Property = new ClsPropertyDAL();
        DataSet dst = cls_Property.SetOrGetCorporationDataSet;

        if (dst != null && dst.Tables[0].Rows.Count > 0)
        {
            string strIndex = this.txtGo.Text.Trim();
            this.txtGo.Text = String.Empty;

            if (strIndex != "")
            {
                try
                {
                    int intIndex = Int32.Parse(strIndex) - 1;

                    if (intIndex >= 0 && intIndex < this.dgrdResult.PageCount)
                    {
                        this.BindIntoValidateByDataView(dst, intIndex);
                    }
                    else
                    {
                        this.Page.RegisterClientScriptBlock("Js", "<script>alert('请输入正确的页码数！')</script>");
                    }
                }
                catch
                {
                    this.Page.RegisterClientScriptBlock("Js", "<script>alert('请输入数字类型的页码！')</script>");
                }
            }
            else
            {
                this.Page.RegisterClientScriptBlock("Js", "<script>alert('请输入要跳转的页码！')</script>");
            }
        }
    }

    /// <summary>
    /// 主表或从表刷新
    /// </summary>
    protected void ibtnRef_Click(object sender, ImageClickEventArgs e)
    {
        int intCommand = Int32.Parse(((ImageButton)sender).CommandName);

        if (intCommand == 0)//刷新主表
        {
            this.GetIntoValidateByMain();
        }
        else//刷新从表
        {

        }
    }

    /// <summary>
    /// 数据控件绑定数据项后被触发的事件
    /// </summary>
    protected void dgrdResult_ItemDataBound(object sender, DataGridItemEventArgs e)
    {
        if (e.Item.ItemIndex != -1)
        {
            bool Is_audit = bool.Parse(e.Item.Cells[1].Text.Trim());
            Boolean bValidState = Boolean.Parse(e.Item.Cells[2].Text.Trim());

            CheckBox chkRsSelect = (CheckBox)e.Item.FindControl("chkRsSelect");
            CuTextBox ctbRs1 = (CuTextBox)e.Item.FindControl("ctbRs1");
            ImageButton ibtnRsEdit = (ImageButton)e.Item.FindControl("ibtnRsEdit");
            ImageButton ibtnRsCancel = (ImageButton)e.Item.FindControl("ibtnRsCancel");
            ImageButton ibtnRsServer = (ImageButton)e.Item.FindControl("ibtnRsServer");
            ImageButton ibtnRsOAudit = (ImageButton)e.Item.FindControl("ibtnRsOAudit");

            Label labValid = (Label)e.Item.FindControl("labValid");
            labValid.Text = (!Is_audit) ? "未确认" : "已确认";

            //修改按回车提交
            if (ctbRs1.ReadOnly)
            {
                ctbRs1.Attributes.Add("onkeydown", "if(event.keyCode == 13){document.getElementById('" + ibtnRsServer.ClientID + "').click();}");
            }

            string strButtonEdit = this.hidButtonEdit.Value;
            string strButtonOAudit = this.hidButtonOAudit.Value;

            if (!Is_audit)
            {
                if (strButtonEdit.Trim() == "1")
                {
                    if (this.panAudit.Visible || this.panDelete.Visible)
                    {
                        chkRsSelect.Visible = true;
                    }

                    ibtnRsEdit.Visible = true;
                }
                else if (this.panAudit.Visible || this.panDelete.Visible)
                {
                    chkRsSelect.Visible = true;
                }
            }
            else
            {
                ibtnRsOAudit.Visible = true;

                if (strButtonOAudit.Trim() != "5")
                {
                    ibtnRsOAudit.Enabled = false;
                    ibtnRsOAudit.ImageUrl = "../App_Images/ico/17.gif";
                }                
            }
        }
    }   

    protected void dgrdChildResult_ItemDataBound(object sender, DataGridItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
        {
            string strbodNoAndDate = this.labbodNoAndDate.Text.ToString();
            string strbodNo = "";
            string strDate = "";
            string[] arrBodAndDate = strbodNoAndDate.Split(new Char[] { '*' });
            if (arrBodAndDate.Length > 1)
            {
                strbodNo = arrBodAndDate[0];//单据号
                strDate = arrBodAndDate[1];//单据日期
            }
            string ctbChildIm_no = ((CuTextSelectBox)e.Item.FindControl("ctsbChildRs0")).Text.Trim();//商品ID
            string ctbChildBatch_no = ((CuTextBox)e.Item.FindControl("ctbChildRsBatchNo")).Text.Trim();//批号
            int ctbChildQty = int.Parse(((CuTextBox)e.Item.FindControl("ctbChildRsQty")).Text.Trim());//商品数量

            Label labGenIdentifyNo = (Label)e.Item.FindControl("labGenIdentifyNo");
            labGenIdentifyNo.Text = "<input type='button'style='width:50px; height:20px;' onclick=\"ModalDialog('../WebCustomUserControls/SelectIdentifyNo.aspx?ParBod_No=" + strbodNo + "&ParBod_Date=" + strDate +
                "&ParIm_No=" + ctbChildIm_no + "&ParBatch_no=" + ctbChildBatch_no + "&ParQty=" + ctbChildQty + "', 440, 400)\" value='选择...' />";
            
        }
    }

    protected void dgrdResult_ItemCreated1(object sender, DataGridItemEventArgs e)
    {
        if (e.Item.ItemType.ToString() == "Item" || e.Item.ItemType.ToString() == "AlternatingItem")
        {
            DataGrid dgrdChildResult = (DataGrid)e.Item.FindControl("dgrdChildResult");

            //子DataGrid注册事件
            dgrdChildResult.ItemDataBound += new DataGridItemEventHandler(dgrdChildResult_ItemDataBound);
        }
    }

    //根据订单状态进行相关查询
    public void lbtnQuery_Click(object sender, EventArgs e)
    {
        int intCommandName = Int32.Parse(((LinkButton)sender).CommandName);

        this.QueryOrderByStatu(intCommandName);
    }

    private void QueryOrderByStatu(int CommandName)
    {
        ClsPropertyDAL cls_Property = new ClsPropertyDAL();
        string strUserID = cls_Property.SetOrGetUserID;

        if (strUserID != "")
        {
            ClsStockManageDAL cls_StockManage = new ClsStockManageDAL();
            DataSet dst = cls_StockManage.GetStockValidateByStatu(strUserID, "tboStockAffirmM", int.Parse(strType), CommandName);
            
            cls_Property.SetOrGetCorporationDataSet = dst;
            this.BindIntoValidateByDataView(dst, 0);           
        }
    }         
}
